﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.gradeinfo
{
    public partial class ModifyYX : lcs.Web.Admin.BasePage
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    int gdid = (Convert.ToInt32(Request.Params["id"]));
                    ShowInfo(gdid);
                }
            }
        }

        private void ShowInfo(int gdid)
        {
            lcs.BLL.gradeinfo bll = new lcs.BLL.gradeinfo();
            lcs.Model.gradeinfo model = bll.GetModel(gdid);
            this.lblgdid.Text = model.gdid.ToString();
            this.txtyxgzs.Text = model.yxgzs.ToString();
            this.txtyxgze.Text = model.yxgze.ToString();
            this.txtyxbfs.Text = model.yxbfs.ToString();
            this.txtyxbfe.Text = model.yxbfe.ToString();
            this.txtyxsum.Text = model.yxsum.ToString();

        }

        public void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            int gdid = int.Parse(this.lblgdid.Text);
            //int monthsupplyid=int.Parse(this.txtmonthsupplyid.Text);
            decimal yxgzs = decimal.Parse(this.txtyxgzs.Text);
            decimal yxgze = decimal.Parse(this.txtyxgze.Text);
            decimal yxbfs = decimal.Parse(this.txtyxbfs.Text);
            decimal yxbfe = decimal.Parse(this.txtyxbfe.Text);
            decimal yxsum = decimal.Parse(this.txtyxsum.Text);
            lcs.Model.gradeinfo model = new lcs.Model.gradeinfo();
            model.gdid = gdid;

            model.yxgzs = yxgzs;
            model.yxgze = yxgze;
            model.yxbfs = yxbfs;
            model.yxbfe = yxbfe;
            model.yxsum = yxsum;
            decimal jg = 0;
            //=IF(X7/W7+Z7/Y7<=0.08,40-X7/W7*500-Z7/Y7*500,0)
            jg = yxgze / yxgzs+ yxbfe/ yxbfs;
            if (jg <= 0.08M)
            {
                jg = 40 - jg * 500;
            }
            else
                jg = 0;

            model.yxzlmark = jg;                      
            model.pfdatetime = DateTime.Now;
            lcs.BLL.gradeinfo bll = new lcs.BLL.gradeinfo();
            bll.UpdateYX(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "mylist.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("mylist.aspx");
        }
    }
}
